package com.elitel.frame.web.cfgtablequerysql.service.impl;

import com.elitel.frame.web.cfgtablequerysql.dao.CfgTableQuerySqlDao;
import com.elitel.frame.web.cfgtablequerysql.entity.CfgTableQuerySql;
import com.elitel.frame.web.cfgtablequerysql.service.CfgTableQuerySqlService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 服务查询列sql文表(BaseQuerysql)表服务实现类
 *
 * @author makejava
 * @since 2025-05-19 16:33:24
 */
@Service
public class CfgTableQuerySqlServiceImpl implements CfgTableQuerySqlService {
    @Resource
    private CfgTableQuerySqlDao cfgTableQuerySqlDao;

    /**
     * 通过ID查询单条数据
     *
     * @param guid 主键
     * @return 实例对象
     */
    @Override
    public CfgTableQuerySql queryById(String guid) {
        return this.cfgTableQuerySqlDao.queryById(guid);
    }


    /**
     * 新增数据
     *
     * @param cfgTableQuerySql 实例对象
     * @return 实例对象
     */
    @Override
    public CfgTableQuerySql insert(CfgTableQuerySql cfgTableQuerySql) {
        this.cfgTableQuerySqlDao.insert(cfgTableQuerySql);
        return cfgTableQuerySql;
    }

    /**
     * 修改数据
     *
     * @param cfgTableQuerySql 实例对象
     * @return 实例对象
     */
    @Override
    public CfgTableQuerySql update(CfgTableQuerySql cfgTableQuerySql) {
        this.cfgTableQuerySqlDao.update(cfgTableQuerySql);
        return this.queryById(cfgTableQuerySql.getGuid());
    }

    /**
     * 通过主键删除数据
     *
     * @param guid 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String guid) {
        return this.cfgTableQuerySqlDao.deleteById(guid) > 0;
    }
}
